<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <script type="text/javascript" src="https://z.moatads.com/addthismoatframe568911941483/moatframe.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>类别[[${category.categoryName}]]中的视频</title>
    <meta name="viewport"
          content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <meta name="description" content="高速在线观看，无需下载播放器。">
    <meta name="keywords" content="电影">
    <meta name="generator" content="CMS">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link th:href="@{/video/pagination.min.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/video/detail/all-responsive-metal.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/video/detail/jquery.fancybox-metal.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/video/category/category.css}" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

    <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script th:src="@{/video/pagination.min.js}" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
</head>

<body class="no-touch">

<div class="top-links">
    <div class="center-hold">
        <div class="network">
            <strong></strong>
            <ul>
            </ul>
        </div>

        <div class="box tags-cloud">
            <a class="highlight" th:each="item:${categoryList}"
               th:style="${item.categoryId ==category.categoryId} ?'color: #bfd128':''"
               th:href="@{'/video/category?categoryId='+${item.categoryId}}">[[${item.categoryName}]] &nbsp;&nbsp;
            </a>
        </div>
        <div class="member-links">
            <ul>
                <li><a href="/video">首页</a></li>
                <ul th:if="${authMpEnabled==true}">
                    <li th:if="${user?.id}"><a href="/logout">注销</a></li>
                    <li th:unless="${user?.id}"><a href="/login">登录</a></li>
                </ul>
            </ul>
        </div>
    </div>
</div>
<div class="container">
    <input type="hidden" th:value="${category.categoryId}" name="categoryId" id="categoryId"/>

    <!--    <div class="header">-->
    <!--        <div class="logo">-->
    <!--            <a href="javascript:"></a>-->
    <!--        </div>-->
    <!--        <div class="social-bookmarks">-->
    <!--            <div class="addthis_toolbox addthis_default_style addthis_32x32_style">-->
    <!--                <div class="atclear" tabindex="1000"></div>-->
    <!--            </div>-->
    <!--        </div>-->

    <!--        <div class="search" style="display: none">-->
    <!--            <form id="user-form">-->
    <!--                <span id="search" class="search-button">搜索</span>-->
    <!--                <div class="search-text"><input type="text" name="name" required placeholder="请输入搜索关键词,至少两个字符" value="">-->
    <!--                </div>-->
    <!--            </form>-->
    <!--        </div>-->
    <!--    </div>-->
    <div class="content">
        <div class="main-content">

            <div class="main-container">
                <div id="list_videos_common_videos_list">

                    <div class="headline">
                        <h1> 类别[[${category.categoryName}]]中的新视频 </h1>

                        <div class="sort">
                            <span class="icon type-sort"></span>
                            <strong>新的</strong>
                        </div>

                        <div class="sort">
                            <span class="icon type-video"></span>
                            <strong>
                                视频 (2516)
                            </strong>

                        </div>
                    </div>

                    <div class="box">
                        <div class="list-videos">
                            <div class="margin-fix" id="list_videos_common_videos_list_items">
                            </div>
                        </div>
                    </div>

                    <div class="pagination" id="list_videos_most_recent_videos_pagination">
                        <div class="pagination-holder">
                            <ul id="example-3" class="pagination"></ul>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="box tags-cloud">
        </div>


    </div>

    <div class="footer-margin">
        <div class="content">
            <div class="box bottom-adv">
            </div>
        </div>
    </div>
</div>
<div class="footer">
    <div class="footer-wrap">
        <ul class="nav">
            <li><a href="/video">主页</a></li>
        </ul>
        <div class="copyright">
            2012-2020 <a href="/video"></a><br>
        </div>
    </div>
</div>


<script type="text/javascript">


    $('#example-3').pagination({
        total: 10, // 总数据条数
        current: 1, // 当前页码
        length: 12, // 每页数据量
        size: 2, // 显示按钮个数
        /**
         * ajax请求远程数据
         * 此方法阻止按钮渲染
         * 直到调用refresh方法
         * @param  {[object]} options = {
         *      current: options.current,
         *      length: options.length,
         *      total: options.total
         *  }
         * @param  {[function]} refresh 回调函数以刷新分页按钮
         * @param  {[object]} $target [description]
         * @return {[type]}         [description]
         */
        ajax: function (options, refresh, $target) {
            $.showLoading("数据加载中");
            $.ajax({
                type: 'post',
                url: '/video/list',
                data: {
                    pageNum: options.current,
                    pageSize: options.length,
                    categoryId: $('#categoryId').val(), //类目id
                },
                dataType: 'json'
            }).done(function (res) {
                $.hideLoading();
                console.log(res);
                // do something
                // 请务必调用此方法，否则分页按钮不会刷新
                if (res && res.code === 0) {
                    $("#list_videos_common_videos_list_items").empty();
                    let html = "";
                    $.each(res.rows, function (i, row) {
                        var ctx = '';
                        html += '<div class="item  "> '
                            + '<a href="/video/detail?id=' + row.id + '&author=' + row.userId + '" title="' + row.name + '"> <div class="img"> <img class="thumb lazy-load" src="' + row.url + '"'
                            + 'data-original="' + row.url + '" alt="' + row.name + '" data-cnt="5" width="180"'
                            + 'height="135">  </div>  <strong class="' + row.name + '"> ' + row.name + '  </strong>  <div class="wrap">  <div class="duration">' + row.shijianStr + '</div>'
                            + '</div>  <div class="wrap">'
                            + ' <div class="added"><em>' + row.diffDays + '</em></div>'
                            + '   <div class="views">' + row.click + '</div>'
                            + '  </div>'
                            + ' </a>'
                            + ' </div>';
                    });
                    $("#list_videos_common_videos_list_items").html(html);
                }

                refresh({
                    total: res.total,// 可选
                    length: res.length // 可选
                });
            }).fail(function (error) {

            });
        }
    });

    $("#search").click(function () {
        $.showLoading("数据加载中");
        var name = $("input[name='name']").val();
        $.ajax({
            dataType: 'json',
            type: 'post',
            url: '/video/byCategoryList',
            data: {
                "name": name,
                "pageNum": 1,
                "pageSize": 50,
                "categoryId": $('#categoryId').val(), //类目id

            },
            success: function (res) {
                $.hideLoading();
                if (res && res.code === 0) {
                    $("#list_videos_common_videos_list_items").empty();
                    $("#list_videos_most_recent_videos_pagination").css('display', 'none');
                    let html = "";
                    $.each(res.rows, function (i, row) {
                        html += '<div class="item  "> '
                            + '<a href="/video/detail?id=' + row.id + '&author=' + row.userId + '" title="' + row.name + '"> <div class="img"> <img class="thumb lazy-load" src="' + row.url + '"'
                            + 'data-original="' + row.url + '" alt="' + row.name + '" data-cnt="5" width="180"'
                            + 'height="135">  </div>  <strong class="' + row.name + '"> ' + row.name + '  </strong>  <div class="wrap">  <div class="duration">' + row.shijianStr + '</div>'
                            + '</div>  <div class="wrap">'
                            + ' <div class="added"><em>' + row.diffDays + '</em></div>'
                            + '   <div class="views">' + row.click + '</div>'
                            + '  </div>'
                            + ' </a>'
                            + ' </div>';
                    });
                    $("#list_videos_common_videos_list_items").html(html);
                } else {
                    $.hideLoading();
                    $.toast(r.msg);

                }
            }
        });
    });


    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>

</body>

</html>